10
is an integer literal, but the name of an
integer variable is not since its value will be determined at run-time by the
assignments made to it.
Literals are distinguished from constants by having no name. Constants are names for literals that may be re-used.
0 |
dddddd |
For example, 0
, 123
and 45600789
are all
decimal integer literals. 01
and 00345345
are not.
The literal's value is is its usual value as a decimal number. It has the type int.
A hexadecimal integer literal has one of the following forms:
0xhhh |
0Xhhh |
For example, 0xabcd
and 0x12EF
are
hexadecimal integer literals. abcd
and 00Xab
are not.
The literal's value is its usual value as a hexadecimal (base 16) number. It has the type int.
Hexadecimal numbers are useful for writing sets of flags, since encoding individual binary bits is easy in hexadecimal.
A floating-point literal has one of the forms:
nnn.nnn |
nnn. |
.nnn |
It may optionally have an exponent suffix which has one of the forms:
e nnn |
e -nnn |
For example, 1.0
, .1
and 13.0e-2
are all
floating point literals. E10
and 123
are not.
The literal's value is the usual decimal value of the first part, multiplied by 10 to the power of the exponent part, if it is present. It has the type float.
"" |
"ccccccc" |
"
', or an
escape sequence.
The string literal is therefore simply a sequence of characters enclosed in double-
quotation marks. Within the quotation marks certain characters may have their usual
meanings changed using the escape character '\
'. This allows
non-printing characters to be embedded in strings, for example. The compiler converts
escape sequences to the appropriate characters when it parses the string literal.
The following table lists the character escape sequences supported in Pog string literals:
Sequence | Meaning |
---|---|
\n | New line |
\t | Horizontal tab |
\v | Vertical tab |
\b | Backspace |
\r | Carriage return |
\f | Form feed |
\a | Bell |
\\ | Literal backslash |
\' | Literal single-quote mark |
\? | Literal question mark |
Note:
Pog does not support any numeric escape sequences.